home *** CD-ROM | disk | FTP | other *** search
/ Gamers Delight 2 / Gamers Delight 2.iso / Aminet / game / role / Ang261Lib.lha / src / prayer.c < prev    next >
C/C++ Source or Header  |  1994-10-22  |  12KB  |  461 lines

  1. /*
  2.  * prayer.c: code for priest spells 
  3.  *
  4.  * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke 
  5.  *
  6.  * This software may be copied and distributed for educational, research, and
  7.  * not for profit purposes provided that this copyright and statement are
  8.  * included in all such copies. 
  9.  */
  10.  
  11. #include "constant.h"
  12. #include "monster.h"
  13. #include "config.h"
  14. #include "types.h"
  15. #include "externs.h"
  16.  
  17.  
  18. /* Pray like HELL.                    -RAK-     */
  19. void 
  20. pray()
  21. {
  22.     int i, j, item_val, dir;
  23.     int choice, chance, result;
  24.     register spell_type  *s_ptr;
  25.     register struct misc  *m_ptr;
  26.     register struct flags *f_ptr;
  27.     register inven_type   *i_ptr;
  28.  
  29.     free_turn_flag = TRUE;
  30.     if (py.flags.blind > 0)
  31.     msg_print("You can't see to read your prayer!");
  32.     else if (no_light())
  33.     msg_print("You have no light to read by.");
  34.     else if (py.flags.confused > 0)
  35.     msg_print("You are too confused.");
  36.     else if (class[py.misc.pclass].spell != PRIEST)
  37.     msg_print("Pray hard enough and your prayers may be answered.");
  38.     else if (inven_ctr == 0)
  39.     msg_print("But you are not carrying anything!");
  40.     else if (!find_range(TV_PRAYER_BOOK, TV_NEVER, &i, &j))
  41.     msg_print("You are not carrying any Holy Books!");
  42.     else if (get_item(&item_val, "Use which Holy Book?", i, j, 0)) {
  43.     result = cast_spell("Recite which prayer?", item_val, &choice, &chance);
  44.     if (result < 0)
  45.         msg_print("You don't know any prayers in that book.");
  46.     else if (result > 0) {
  47.         s_ptr = &magic_spell[py.misc.pclass - 1][choice];
  48.         free_turn_flag = FALSE;
  49.  
  50.         if (py.flags.stun > 50)
  51.         chance += 25;
  52.         else if (py.flags.stun > 0)
  53.         chance += 15;
  54.         if (randint(100) <= chance)    /* changed -CFT */
  55.         msg_print("You lost your concentration!");
  56.         else {
  57.         /* Prayers.                     */
  58.         switch (choice + 1) {
  59.           case 1:
  60.             (void)detect_evil();
  61.             break;
  62.           case 2:
  63.             (void)hp_player(damroll(3, 3));
  64.             if (py.flags.cut > 0) {
  65.             py.flags.cut -= 10;
  66.             if (py.flags.cut < 0)
  67.                 py.flags.cut = 0;
  68.             msg_print("Your wounds heal.");
  69.             }
  70.             break;
  71.           case 3:
  72.             bless(randint(12) + 12);
  73.             break;
  74.           case 4:
  75.             (void)remove_fear();
  76.             break;
  77.           case 5:
  78.             (void)light_area(char_row, char_col,
  79.              damroll(2, (py.misc.lev / 2)), (py.misc.lev / 10) + 1);
  80.             break;
  81. /* FIXME: hammer? */
  82.           case 6:
  83.             (void)detect_trap();
  84.             break;
  85.           case 7:
  86.             (void)detect_sdoor();
  87.             break;
  88.           case 8:
  89.             (void)slow_poison();
  90.             break;
  91.           case 9:
  92.             if (get_dir(NULL, &dir))
  93.             (void)fear_monster(dir, char_row, char_col, py.misc.lev);
  94.             break;
  95.           case 10:
  96.             teleport((int)(py.misc.lev * 3));
  97.             break;
  98.           case 11:
  99.             (void)hp_player(damroll(4, 4));
  100.             if (py.flags.cut > 0) {
  101.             py.flags.cut = (py.flags.cut / 2) - 20;
  102.             if (py.flags.cut < 0)
  103.                 py.flags.cut = 0;
  104.             msg_print("Your wounds heal.");
  105.             }
  106.             break;
  107.           case 12:
  108.             bless(randint(24) + 24);
  109.             break;
  110.           case 13:
  111.             (void)sleep_monsters1(char_row, char_col);
  112.             break;
  113.           case 14:
  114.             create_food();
  115.             break;
  116.           case 15:
  117.             remove_curse();/* -CFT */
  118.             break;
  119.           case 16:
  120.             f_ptr = &py.flags;
  121.             f_ptr->resist_heat += randint(10) + 10;
  122.             f_ptr->resist_cold += randint(10) + 10;
  123.             break;
  124.           case 17:
  125.             (void)cure_poison();
  126.             break;
  127.           case 18:
  128.             if (get_dir(NULL, &dir))
  129.             fire_ball(GF_HOLY_ORB, dir, char_row, char_col,
  130.                   (int)(damroll(3,6)+py.misc.lev+
  131.                     (py.misc.pclass==2 ? 2 : 1)*stat_adj(A_WIS)),
  132.                   (py.misc.lev<30 ? 2 : 3));
  133.             break;
  134.           case 19:
  135.             (void)hp_player(damroll(8, 4));
  136.             if (py.flags.cut > 0) {
  137.             py.flags.cut = 0;
  138.             msg_print("Your wounds heal.");
  139.             }
  140.             break;
  141.           case 20:
  142.             detect_inv2(randint(24) + 24);
  143.             break;
  144.           case 21:
  145.             (void)protect_evil();
  146.             break;
  147.           case 22:
  148.             earthquake();
  149.             break;
  150.           case 23:
  151.             map_area();
  152.             break;
  153.           case 24:
  154.             (void)hp_player(damroll(16, 4));
  155.             if (py.flags.cut > 0) {
  156.             py.flags.cut = 0;
  157.             msg_print("Your wounds heal.");
  158.             }
  159.             break;
  160.           case 25:
  161.             (void)turn_undead();
  162.             break;
  163.           case 26:
  164.             bless(randint(48) + 48);
  165.             break;
  166.           case 27:
  167.             (void)dispel_creature(UNDEAD, (int)(3 * py.misc.lev));
  168.             break;
  169.           case 28:
  170.             (void)hp_player(200);
  171.             if (py.flags.stun > 0) {
  172.             if (py.flags.stun > 50) {
  173.                 py.misc.ptohit += 20;
  174.                 py.misc.ptodam += 20;
  175.             } else {
  176.                 py.misc.ptohit += 5;
  177.                 py.misc.ptodam += 5;
  178.             }
  179.             py.flags.stun = 0;
  180.             msg_print("Your head stops stinging.");
  181.             }
  182.             if (py.flags.cut > 0) {
  183.             py.flags.cut = 0;
  184.             msg_print("You feel better.");
  185.             }
  186.             break;
  187.           case 29:
  188.             (void)dispel_creature(EVIL, (int)(3 * py.misc.lev));
  189.             break;
  190.           case 30:
  191.             warding_glyph();
  192.             break;
  193.           case 31:
  194.             (void)dispel_creature(EVIL, (int)(4 * py.misc.lev));
  195.             (void)remove_fear();
  196.             (void)cure_poison();
  197.             (void)hp_player(1000);
  198.             if (py.flags.stun > 0) {
  199.             if (py.flags.stun > 50) {
  200.                 py.misc.ptohit += 20;
  201.                 py.misc.ptodam += 20;
  202.             } else {
  203.                 py.misc.ptohit += 5;
  204.                 py.misc.ptodam += 5;
  205.             }
  206.             py.flags.stun = 0;
  207.             msg_print("Your head stops stinging.");
  208.             }
  209.             if (py.flags.cut > 0) {
  210.             py.flags.cut = 0;
  211.             msg_print("You feel better.");
  212.             }
  213.             break;
  214.           case 32:
  215.             (void)detect_monsters();
  216.             break;
  217.           case 33:
  218.             (void)detection();
  219.             break;
  220.           case 34:
  221.             (void)ident_spell();
  222.             break;
  223.           case 35:       /* probing */
  224.             (void)probing();
  225.             break;
  226.           case 36:       /* Clairvoyance */
  227.             wizard_light(TRUE);
  228.             break;
  229.           case 37:
  230.             (void)hp_player(damroll(8, 4));
  231.             if (py.flags.cut > 0) {
  232.             py.flags.cut = 0;
  233.             msg_print("Your wounds heal.");
  234.             }
  235.             break;
  236.           case 38:
  237.             (void)hp_player(damroll(16, 4));
  238.             if (py.flags.cut > 0) {
  239.             py.flags.cut = 0;
  240.             msg_print("Your wounds heal.");
  241.             }
  242.             break;
  243.           case 39:
  244.             (void)hp_player(2000);
  245.             if (py.flags.stun > 0) {
  246.             if (py.flags.stun > 50) {
  247.                 py.misc.ptohit += 20;
  248.                 py.misc.ptodam += 20;
  249.             } else {
  250.                 py.misc.ptohit += 5;
  251.                 py.misc.ptodam += 5;
  252.             }
  253.             py.flags.stun = 0;
  254.             msg_print("Your head stops stinging.");
  255.             }
  256.             if (py.flags.cut > 0) {
  257.             py.flags.cut = 0;
  258.             msg_print("You feel better.");
  259.             }
  260.             break;
  261.           case 40:       /* restoration */
  262.             if (res_stat(A_STR))
  263.             msg_print("You feel warm all over.");
  264.             if (res_stat(A_INT))
  265.             msg_print("You have a warm feeling.");
  266.             if (res_stat(A_WIS))
  267.             msg_print("You feel your wisdom returning.");
  268.             if (res_stat(A_DEX))
  269.             msg_print("You feel less clumsy.");
  270.             if (res_stat(A_CON))
  271.             msg_print("You feel your health returning!");
  272.             if (res_stat(A_CHR))
  273.             msg_print("You feel your looks returning.");
  274.             break;
  275.           case 41:       /* rememberance */
  276.             (void)restore_level();
  277.             break;
  278.           case 42:       /* dispel undead */
  279.             (void)dispel_creature(UNDEAD, (int)(4 * py.misc.lev));
  280.             break;
  281.           case 43:       /* dispel evil */
  282.             (void)dispel_creature(EVIL, (int)(4 * py.misc.lev));
  283.             break;
  284.           case 44:       /* banishment */
  285.             if (banish_creature(EVIL, 100))
  286.             msg_print("The Power of your god banishes the creatures!");
  287.             break;
  288.           case 45:       /* word of destruction */
  289.             destroy_area(char_row, char_col);
  290.             break;
  291.           case 46:       /* annihilation */
  292.             if (get_dir(NULL, &dir))
  293.             drain_life(dir, char_row, char_col, 200);
  294.             break;
  295.           case 47:       /* unbarring ways */
  296.             (void)td_destroy();
  297.             break;
  298.           case 48:       /* recharging */
  299.             (void)recharge(15);
  300.             break;
  301.           case 49:       /* dispel curse */
  302.             (void)remove_all_curse();
  303.             break;
  304.           case 50:       /* enchant weapon */
  305.             i_ptr = &inventory[INVEN_WIELD];
  306.             if (i_ptr->tval != TV_NOTHING) {
  307.             char tmp_str[100], out_val[100];
  308.             
  309.             objdes(tmp_str, i_ptr, FALSE);
  310.             sprintf(out_val, "Your %s glows brightly!", tmp_str);
  311.             msg_print(out_val);
  312.             if (!enchant(i_ptr, randint(4), ENCH_TOHIT|ENCH_TODAM))
  313.                 msg_print("The enchantment fails.");
  314.             }
  315.             break;
  316.           case 51:       /* enchant armor */
  317.             if (1) {
  318.             int                 k = 0;
  319.             int                 l = 0;
  320.             int                 tmp[100];
  321.  
  322.             if (inventory[INVEN_BODY].tval != TV_NOTHING)
  323.                 tmp[k++] = INVEN_BODY;
  324.             if (inventory[INVEN_ARM].tval != TV_NOTHING)
  325.                 tmp[k++] = INVEN_ARM;
  326.             if (inventory[INVEN_OUTER].tval != TV_NOTHING)
  327.                 tmp[k++] = INVEN_OUTER;
  328.             if (inventory[INVEN_HANDS].tval != TV_NOTHING)
  329.                 tmp[k++] = INVEN_HANDS;
  330.             if (inventory[INVEN_HEAD].tval != TV_NOTHING)
  331.                 tmp[k++] = INVEN_HEAD;
  332.             /* also enchant boots */
  333.             if (inventory[INVEN_FEET].tval != TV_NOTHING)
  334.                 tmp[k++] = INVEN_FEET;
  335.  
  336.             if (k > 0)
  337.                 l = tmp[randint(k) - 1];
  338.             if (TR_CURSED & inventory[INVEN_BODY].flags)
  339.                 l = INVEN_BODY;
  340.             else if (TR_CURSED & inventory[INVEN_ARM].flags)
  341.                 l = INVEN_ARM;
  342.             else if (TR_CURSED & inventory[INVEN_OUTER].flags)
  343.                 l = INVEN_OUTER;
  344.             else if (TR_CURSED & inventory[INVEN_HEAD].flags)
  345.                 l = INVEN_HEAD;
  346.             else if (TR_CURSED & inventory[INVEN_HANDS].flags)
  347.                 l = INVEN_HANDS;
  348.             else if (TR_CURSED & inventory[INVEN_FEET].flags)
  349.                 l = INVEN_FEET;
  350.  
  351.             if (l > 0) {
  352.                 char                out_val[100], tmp_str[100];
  353.  
  354.                 i_ptr = &inventory[l];
  355.                 objdes(tmp_str, i_ptr, FALSE);
  356.                 sprintf(out_val, "Your %s glows faintly!", tmp_str);
  357.                 msg_print(out_val);
  358.                 if (!enchant(i_ptr, randint(3)+1, ENCH_TOAC))
  359.                 msg_print("The enchantment fails.");
  360.             }
  361.             }
  362.             break;
  363.           case 52:       /* Elemental brand */
  364.             i_ptr = &inventory[INVEN_WIELD];
  365.             if (i_ptr->tval != TV_NOTHING &&
  366.             i_ptr->name2 == SN_NULL &&
  367.             !(i_ptr->flags & TR_CURSED)) {
  368.  
  369. /* you can't create an ego weapon from a cursed object...
  370.  * the curse would "taint" the magic -CFT
  371.  */
  372.  
  373.             int hot = randint(2)-1;
  374.             char tmp_str[100], out_val[100];
  375.  
  376.             objdes(tmp_str, i_ptr, FALSE);
  377.             if (hot) {
  378.                 sprintf(out_val,
  379.                     "Your %s is covered in a fiery shield!",
  380.                     tmp_str);
  381.                 i_ptr->name2 |= SN_FT;
  382.                 i_ptr->flags |= (TR_FLAME_TONGUE | TR_RES_FIRE);
  383.             } else {
  384.                 sprintf(out_val, "Your %s glows deep, icy blue!",
  385.                     tmp_str);
  386.                 i_ptr->name2 |= SN_FB;
  387.                 i_ptr->flags |= (TR_FROST_BRAND | TR_RES_COLD);
  388.             }
  389.             msg_print(out_val);
  390.             enchant(i_ptr, 3+randint(3), ENCH_TOHIT|ENCH_TODAM);
  391.             calc_bonuses();
  392.             } else {
  393.             msg_print("The Branding fails.");
  394.             }
  395.             break;
  396.           case 53:       /* blink */
  397.             teleport(10);
  398.             break;
  399.           case 54:       /* teleport */
  400.             teleport((int)(py.misc.lev * 8));
  401.             break;
  402.           case 55:       /* teleport away */
  403.             if (get_dir(NULL, &dir))
  404.             (void)teleport_monster(dir, char_row, char_col);
  405.             break;
  406.           case 56:       /* teleport level */
  407.             (void)tele_level();
  408.             break;
  409.           case 57:       /* word of recall */
  410.             if (py.flags.word_recall == 0) {
  411.             py.flags.word_recall = 15 + randint(20);
  412.             msg_print("The air about you becomes charged...");
  413.             } else {
  414.             py.flags.word_recall = 0;
  415.             msg_print("A tension leaves the air around you...");
  416.             }
  417.             break;
  418.           case 58:       /* alter reality */
  419.             new_level_flag = TRUE;
  420.             break;
  421.           default:
  422.             break;
  423.         }
  424.         /* End of prayers.                 */
  425.         if (!free_turn_flag) {
  426.             m_ptr = &py.misc;
  427.             if (choice < 32) {
  428.             if ((spell_worked & (1L << choice)) == 0) {
  429.                 m_ptr->exp += s_ptr->sexp << 2;
  430.                 spell_worked |= (1L << choice);
  431.                 prt_experience();
  432.             }
  433.             } else {
  434.             if ((spell_worked2 & (1L << (choice - 32))) == 0) {
  435.                 m_ptr->exp += s_ptr->sexp << 2;
  436.                 spell_worked2 |= (1L << (choice - 32));
  437.                 prt_experience();
  438.             }
  439.             }
  440.         }
  441.         }
  442.         m_ptr = &py.misc;
  443.         if (!free_turn_flag) {
  444.         if (s_ptr->smana > m_ptr->cmana) {
  445.             msg_print("You faint from fatigue!");
  446.             py.flags.paralysis =
  447.             randint((int)(5 * (s_ptr->smana - m_ptr->cmana)));
  448.             m_ptr->cmana = 0;
  449.             m_ptr->cmana_frac = 0;
  450.             if (randint(3) == 1) {
  451.             msg_print("You have damaged your health!");
  452.             (void)dec_stat(A_CON);
  453.             }
  454.         } else
  455.             m_ptr->cmana -= s_ptr->smana;
  456.         prt_cmana();
  457.         }
  458.     }
  459.     }
  460. }
  461.